{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" class="layui-input search" name="user_email" placeholder="邮箱"/>
                        </div>

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" class="layui-input search" name="user_xing" placeholder="姓"/>
                        </div>

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" class="layui-input search" name="user_name" placeholder="名"/>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="user_status">
                                <option value="">---- 不限状态 ----</option>
                                <option value="-1" >未提交审核</option>
                                <option value="1" >待审核</option>
                                <option value="2" >审核通过</option>
                                <option value="3" >审核拒绝</option>
                                <option value="4" >已冻结</option>
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>
                <!--操作框开始-->
                <div class="col-sm-12">
                    <div class="input-group" >
<!--                        <button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">-->
<!--                            <i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>-->
<!--                        </button>-->
<!--                        <ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">-->
<!--                            <li><a  href="javascript:;" class="layuiBtn" data-type="batchUpdateTag"> 设置标签</a></li>-->
<!--                            <li><a  href="javascript:;" class="layuiBtn" data-type="batchOutExcel"> 导出</a></li>-->
<!--                        </ul>-->
                    </div>
                </div>
                <!--操作框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>

                    <!--图片模板-->
<!--                    <script type="text/html" id="imgTpl">-->
<!--                        <img src="{{d.user_image}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"/>-->
<!--                    </script>-->

                    <!--状态显示模板-->
                    <script type="text/html" id="userStat">
                        {{# if(d.user_status == -1){ }}
                        <span style="color: green">未提交审核</span>
                        {{# } }}
                        {{# if(d.user_status == 1){ }}
                        <span style="color: red">待审核</span>
                        {{# } }}
                        {{# if(d.user_status == 2){ }}
                        <span style="color: darkgoldenrod">审核通过</span>
                        {{# } }}
                        {{# if(d.user_status == 3){ }}
                        <span style="color: deeppink">审核拒绝</span>
                        {{# } }}
                        {{# if(d.user_status == 4){ }}
                        <span style="color: orange">冻结</span>
                        {{# } }}
                    </script>

                    <!--操作模板-->
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.layer_show('详情','{:url('memberDetail')}?user_id={{d.user_id}}')" class="btn btn-warning btn-xs m-r-xs" title="详情">详情</a>
                        {{# if(d.user_status == 1) { }}

                        {{# if(d.user_type == 0) { }}
                        <a href="javascript:;" onclick="wk.layer_show('审核通过', '{:url('checkPass')}?user_id={{d.user_id}}')" class="btn btn-primary btn-xs m-r-xs" title="通过">通过</a>
                        {{# }else{ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}', '{:url('confirmCheckPass')}', '确定审核通过？')" class="btn btn-primary btn-xs m-r-xs" title="通过">通过</a>
                        {{# } }}
                        <a href="javascript:;" onclick="wk.layer_show('审核拒绝', '{:url('checkRefuse')}?user_id={{d.user_id}}')" class="btn btn-danger btn-xs m-r-xs" title="拒绝">拒绝</a>

                        {{# } }}

                        {{# if(d.user_status == 2) { }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}', '{:url('changeStatus')}', '确定冻结？')" class="btn btn-warning btn-xs m-r-xs" title="冻结">冻结</a>
                        {{# } }}

                        {{# if(d.user_status == 4) { }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}', '{:url('changeStatus')}', '确定启用？')" class="btn btn-primary btn-xs m-r-xs" title="启用">启用</a>
                        {{# } }}

                        <a href="javascript:;" onclick="wk.layer_show('编辑', '{:url('memberEdit')}?user_id={{d.user_id}}')" class="btn btn-primary btn-xs m-r-xs" title="编辑">编辑</a>
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('memberDel')}')" class="btn btn-danger btn-xs m-r-xs" title="删除">删除</a>
                        <a href="javascript:;" onclick="wk.layer_show('收藏','{:url('memberCollect')}?user_id={{d.user_id}}')" class="btn btn-warning btn-xs m-r-xs" title="收藏">收藏</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Member/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
               // {type: 'checkbox', fixed: 'left',}
//                 {type:'numbers', width: 60, title: '序号'}
                {field: 'user_id', width: 80, title: 'ID', align: 'center'}
                , {field: 'user_xing', width: '', title: '姓', align: 'center'}
                , {field: 'user_name', width: '', title: '名', align: 'center'}
                , {field: 'user_email', width: '', title: '邮箱', align: 'center'}
                , {field: 'user_status', width: 100, title: '用户状态', align: 'center', toolbar: '#userStat'}
                , {field: 'user_phone', width: '', title: '电话', align: 'center'}
                , {field: 'user_company', width: '', title: '公司', align: 'center'}
                , {field: 'user_position', width: 100, title: '职位', align: 'center'}
                , {field: 'user_time', width: 160, title: '注册时间', align: 'center'}
                , {fixed: 'right', width:300, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.img-circle').viewer({
                    url: 'data-original',
                });
            }
        });

        //批量操作
        var $ = layui.$, active = {
            //批量修改标签
            batchUpdateTag:function () {
                user_ids = getIds();
                if(user_ids.length == 0){
                    alert('请选择需要修改的数据');
                }else {
                    wk.layer_show('批量修改标签', "{:url('admin/Member/batchUpdateTag')}?ids=" + user_ids);
                }
            },
            //批量导出
            batchOutExcel:function () {
                wk.excelAll(getIds(),$('.layui-input').serialize(),"{:url('outExcel')}");
            }
        };

        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['user_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>